<?php
//开启会话
session_start();
$adminName = trim($_POST['adminName']);
include_once 'connect.php';
$article = "select * from article order by id desc";
$resarticle = mysqli_query($connect, $article);
?>
<?php
include_once 'connect.php';
$sql = "select * from text where adminName = '" . $_SESSION['loginadmin'] . " ' ";
$result = mysqli_query($connect, $sql);
if (mysqli_num_rows($result)) {
    $text = mysqli_fetch_array($result);
} else {
    header("Location:login.php");
    die("参数错误");
}
?>

<?php
 include_once 'Nav.php';
?>

<link href="/admin/assets/css/vendor/dataTables.bootstrap4.css" rel="stylesheet" type="text/css" />
<link href="/admin/assets/css/vendor/responsive.bootstrap4.css" rel="stylesheet" type="text/css" />
<link href="/admin/assets/css/vendor/buttons.bootstrap4.css" rel="stylesheet" type="text/css" />
<link href="/admin/assets/css/vendor/select.bootstrap4.css" rel="stylesheet" type="text/css" />
<!-- third party css end -->

<div class="row">
    <div class="col-12">
        <div class="card">
            <div class="card-body">
                <h4 class="header-title mb-3 size_18">点点滴滴
                    <a class="fabu" href="/admin/littleAdd.php">
                    <button type="button" class="btn btn-success btn-sm right_10">
                        <i class="mdi mdi-circle-edit-outline"></i>新增</button></a></h4>
                <table id="basic-datatable" class="table dt-responsive nowrap" width="100%">
                    <thead>
                    <tr>
                        <th>标题</th>
                        <th>发布时间</th>
                        <th>发布者</th>
                        <th style="width:150px;">操作</th>
                    </tr>
                    </thead>


                    <tbody>
                    <?php
                    while ($info = mysqli_fetch_array($resarticle)) {
                    ?>
                    <tr>
                        <td><?php echo $info['articletitle']?></td>
                        <td><?php echo $info['articletime']?></td>
                        <td><?php echo $info['articlename']?></td>
                        <td>
                            <a href= "modlitt.php?id=<?php echo $info['id']?>">
                                <button type="button" class="btn btn-secondary btn-rounded">
                                    <i class=" mdi mdi-clipboard-text-play-outline mr-1"></i>修改</button></a>
                            <a href="javascript:del(<?php echo $info['id']; ?>,'<?php echo $info['articletitle'];?>');">
                                <button type="button" class="btn btn-danger btn-rounded">
                                    <i class=" mdi mdi-delete-empty mr-1"></i>删除</button></a></td>
                    </tr>
                        <?php
                    }
                    ?>
                    </tbody>
                </table>

            </div> <!-- end card body-->
        </div> <!-- end card -->
    </div><!-- end col-->
</div>





    <script>
        function del(id,articletitle){
            if (confirm('您确认要删除标题为 '+ articletitle + ' 的文章吗')){
                location.href = 'dellitt.php?id=' + id + '&title' + articletitle;
            }
        }
        // function mod(id,articletitle,articletext){
        //     if (confirm('是否确认修改标题为 '+ articletitle + ' 的文章')){
        //         location.href = 'modlitt.php?id=' + id +  '&title'+ articletitle + '&text' + articletext ;
        //     }
        // }
    </script>
<?php
include_once 'Footer.php';
?>
<!-- third party js -->
<script src="/admin/assets/js/vendor/jquery.dataTables.min.js"></script>
<script src="/admin/assets/js/vendor/dataTables.bootstrap4.js"></script>
<script src="/admin/assets/js/vendor/dataTables.responsive.min.js"></script>
<script src="/admin/assets/js/vendor/responsive.bootstrap4.min.js"></script>
<script src="/admin/assets/js/vendor/dataTables.buttons.min.js"></script>
<script src="/admin/assets/js/vendor/buttons.bootstrap4.min.js"></script>
<script src="/admin/assets/js/vendor/buttons.html5.min.js"></script>
<script src="/admin/assets/js/vendor/buttons.flash.min.js"></script>
<script src="/admin/assets/js/vendor/buttons.print.min.js"></script>
<script src="/admin/assets/js/vendor/dataTables.keyTable.min.js"></script>
<script src="/admin/assets/js/vendor/dataTables.select.min.js"></script>
<!-- third party js ends -->
<!-- demo app -->
<script src="/admin/assets/js/pages/demo.datatable-init.js"></script>
<!-- end demo js-->

</body>
</html>